package IC.Types;

/**
 * Created by IntelliJ IDEA.
 * User: nimrod
 * Date: 09/01/12
 * Time: 14:09
 * To change this template use File | Settings | File Templates.
 */
public class PrimitiveType extends Type {

    private PrimitiveTypeKind kind;

    public PrimitiveType(PrimitiveTypeKind kind) {
        super(kind.getName());

        this.kind = kind;
    }

    @Override
    public boolean subtypeOf(Type t) {
        if (this.kind == PrimitiveTypeKind.NULL) {
            return t.isReferenceType();
        }
        
        return t == this;
    }

    @Override
    public boolean isReferenceType() {
        return this.kind == PrimitiveTypeKind.STRING || this.kind == PrimitiveTypeKind.NULL;
    }

    @Override
    public String toString() {
        return this.getId() + ": Primitive type: " + this.getName();
    }
}
